<%#
 Copyright 2013-2019 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<%#
 Copyright 2013-2019 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
apiVersion: <%= KUBERNETES_DEPLOYMENT_API_VERSION %>
kind: Deployment
metadata:
  name: jhipster-logstash
  namespace: <%= kubernetesNamespace %>
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jhipster-logstash
  template:
    metadata:
      labels:
        app: jhipster-logstash
     <%_ if (istio) { _%>
      annotations:
        sidecar.istio.io/inject: "false"
     <%_ } _%>
    spec:
      initContainers:
        - name: init-es-check
          image: busybox
          command:
            - '/bin/sh'
            - '-c'
            - |
                until nc -z -w 1 jhipster-elasticsearch 9200
                do
                  echo Waiting for elasticsearch cluster to get initialized
                  sleep 5
                done
      containers:
      - image: <%= DOCKER_JHIPSTER_LOGSTASH %>
        name: jhipster-logstash
        ports:
        - containerPort: 5000
          protocol: UDP
        - containerPort: 5000
          protocol: TCP
        resources: {}
      restartPolicy: Always
---
apiVersion: <%= KUBERNETES_CORE_API_VERSION  %>
kind: Service
metadata:
  name: jhipster-logstash
  namespace: <%= kubernetesNamespace %>
  labels:
    app: jhipster-logstash
spec:
  ports:
  - name: "udp"
    port: 5000
    protocol: UDP
    targetPort: 5000
  - name: "tcp"
    port: 5000
    protocol: TCP
    targetPort: 5000
  selector:
    app: jhipster-logstash

